{!! Html::style(env("APP_URL").'/assets/backend/admin/css/jquery-ui.min.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/common.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/angular-motion.min.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/order.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/slideGallery.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/printTemplate.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/aiui.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/admin/css/postil.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/libs/jquery-ui-1.9.2/css/ui-lightness/jquery-ui-1.9.2.custom.css') !!}
{!! Html::style(env("APP_URL").'/assets/backend/libs/jqGrid/css/ui.jqgrid.css') !!}
<style type="text/css">
    .operating .ui-icon {
        display: inline-block;
        cursor: pointer;
        margin: 0 5px;
    }

    .ui-droplist-wrap .droplist {
        background-color: #FFFFFF;
        position: relative;
        overflow: auto;
        font-size: 12px;
    }

    .list-item {
        cursor: default;
        line-height: 22px;
        overflow: hidden;
        padding: 2px 5px;
    }

    .extra-list-ctn {
        background: none repeat scroll 0 0 #F5F5F5;
        border-top: 1px solid #DDDDDD;
        padding-left: 5px;
    }

    .btn-normal {
        border: none;
        padding: 0px 20px 0px 20px;
        background-color: rgb(0, 160, 233);
        height: 32px;
        color: #fff;
        border-radius: 0;
        cursor: pointer;
        display: inline-block;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.42857;
        margin-bottom: 0;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
    }

    #pop * {
        margin: 0;
        padding: 0;
    }

    #pop {
        background: #fff;
        width: 260px;
        border: 1px solid #e0e0e0;
        font-size: 12px;
        position: fixed;
        right: 10px;
        bottom: 10px;
        z-index: 1031
    }

    #popHead {
        line-height: 32px;
        background: #f6f0f3;
        border-bottom: 1px solid #e0e0e0;
        position: relative;
        font-size: 12px;
        padding: 0 0 0 10px;
    }

    #popHead h2 {
        font-size: 14px;
        color: #666;
        line-height: 32px;
        height: 32px;
    }

    #popHead #popClose {
        position: absolute;
        right: 10px;
        top: 1px;
    }

    #popHead a#popClose:hover {
        color: #f00;
        cursor: pointer;
    }

    #popContent {
        padding: 5px 10px;
    }

    #popTitle a {
        line-height: 24px;
        font-size: 14px;
        font-family: '微软雅黑';
        color: #333;
        font-weight: bold;
        text-decoration: none;
    }

    #popTitle a:hover {
        color: #f60;
    }

    #popIntro {
        text-indent: 24px;
        line-height: 160%;
        margin: 5px 0;
        color: #666;
    }

    #popMore {
        text-align: right;
        border-top: 1px dotted #ccc;
        line-height: 24px;
        margin: 8px 0 0 0;
    }

    #popMore a {
        color: #f60;
    }

    #popMore a:hover {
        color: #f00;
    }

    .alertmsg {
        display: none;
        position: absolute;
        top: 50%;
        left: 50%;
        text-align: center;
    }
</style>
@include('shop-backend::includes.loading')
<div class="ibox float-e-margins" ng-app="JxApp" style="display: none">
    <div class="ibox-content" ng-controller="OrderModule" id="OrderCtrl">
        <div id="pop" style="display:none;">
            <div id="popHead">
                <a id="popClose" title="关闭" onclick="closeMessage(10);">关闭</a>
                <h2>温馨提示</h2>
            </div>
            <div id="popContent">
                <dl>
                    <dt id="popTitle"></dt>
                    <dd id="popIntro"></dd>
                </dl>
            </div>
        </div>
        <div class="row">
            <div class="panel-body">
                <div class="form-group right-form-container">
                    <table class="table table-bordered">
                        <tbody>
                            @if($order_type=='transfer')
                                <tr>
                                    <td class="td-label"><span class="text-danger">* </span>调出门店：</td>
                                    <td colspan="5">
                                        <div>
                                            <select ng-model="order.outShopId" id="outShopId" style="width: 260px;">
                                                <option value="">请选择</option>
                                                @foreach($shops as $shop)
                                                    <option value="{{ $shop->id }}">{{ $shop->name }}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td-label"><span class="text-danger">* </span>调入门店：</td>
                                    <td colspan="5">
                                        <div>
                                            <select ng-model="order.inShopId" id="inShopId" style="width: 260px;">
                                                <option value="">请选择</option>
                                                @foreach($shops as $shop)
                                                    <option value="{{ $shop->id }}">{{ $shop->name }}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                            @endif
                            <tr>
                                <td class="td-label"><span class="text-danger">* </span>日期：</td>
                                <td class="td-content validate_input">
                                    <div ng-show="!order.businessTime" class="error_container ng-hide">
                                        <div class="error_tip_left">
                                            <div class="error_led_left"><span></span></div>
                                            <span>日期为必选项</span>
                                        </div>
                                    </div>
                                    <input type="text" class="form-control text-input ng-pristine ng-valid-date ng-valid ng-valid-required" datepicker-popup="" ng-model="order.businessTime" show-weeks="false" max="selMaxDate" min="selMinDate" show-button-bar="false" ng-readonly="order.state != 1" required="" style="width: 260px;">
                                </td>
                            </tr>
                            <tr>
                                <td class="td-label">备注：</td>
                                <td colspan="5">
                                    <div>
                                        <input type="text" class="form-control ng-pristine ng-valid" ng-model="order.remark">
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="form-group">
                    <table id="purchaseList"></table>
                    <div id="pager"></div>
                    <div class="btn-group" align="center">
                        <button class="btn-normal" ng-click="saveOrder($event)" ng-disabled="!order.supplierId || order.finalTotalAmount < 0" ng-show="order.state == 1">{{ $button_text }}</button>
                        {{--<button class="btn-normal" ng-disabled="!order.supplierId || order.finalTotalAmount < 0" ng-click="approvalConfirm($event)" ng-show="order.state == 1">采购</button>
                        <button class="btn-normal ng-hide" ng-click="deleteOrder($event)" ng-show="(order.state == 1) && order.purchaseSn">删除</button>
                        <button class="btn-normal ng-hide" ng-click="destroyOrder($event)" ng-show="(order.state == 2 || order.state == 4) && order.purchaseSn">撤销</button>
                        <button class="btn-normal ng-hide" ng-click="goForInStore($event)" ng-show="isOpenWoutOrWinStore && (order.state == 4 || order.state == 5)">去入库</button>
                        <button class="btn-normal ng-hide" ng-click="inStoreByOneTime($event)" ng-show="isOpenWoutOrWinStore && (order.state == 4 || order.state == 5)">全部入库</button>--}}
                    </div>
                </div>
            </div>
        </div>


        {{-- 商品选择弹出框start--}}
        <div ng-show="showAutoGoods" ng-style="autoGoodsStyle" class="ui-droplist-wrap">
            <div class="droplist">
                <div class="list-item" ng-class="{'on':searchGoodAct==$index}" ng-repeat="good in goods" ng-click="selAutoGood(good)">
                    <span ng-bind="good.name"></span>
                    <span ng-bind="good.goods_no"></span>
                </div>
            </div>
            <div class="extra-list-ctn">
                {{--<a target="_blank" href="{{ route('admin.goods.create') }}" class="addGoodTip" ng-if="addGoodTip">没有商品！去添加？</a>--}}
                <span class="goodsLoading" ng-if="!addGoodTip" ng-bind="loaddingMsg"></span>
            </div>
        </div>
        {{-- 商品选择弹出框end--}}

        {{-- 尺寸选择弹出框start--}}
        <div ng-show="showAutoSize" ng-style="autoSizStyle" class="ui-droplist-wrap">
            <div class="droplist">
                <div class="list-item" ng-repeat="size in currentSizes | orderBy:['showOrder','id']" ng-click="selAutoSize(size,$event)"><span ng-bind="size.name"></span></div>
            </div>
            <div class="extra-list-ctn"></div>
        </div>
        {{-- 尺寸选择弹出框end--}}

        {{-- 颜色选择弹出框start--}}
        <div ng-show="showAutoColor" ng-style="autoColorStyle"
             class="ui-droplist-wrap">
            <div class="droplist">
                <div class="list-item" ng-repeat="color in currentColors | orderBy:['showOrder','id']" ng-click="selAutoColor(color,$event)"><span ng-bind="color.name"></span></div>
            </div>
            <div class="extra-list-ctn"></div>
        </div>
        {{-- 颜色选择弹出框end--}}

        {{-- 价格选择弹出框start--}}
        <div ng-show="showAutoPrice" ng-style="autoPriceStyle"
             class="ui-droplist-wrap">
            <div class="droplist">
                <div class="list-item" ng-repeat="price in currentPrices" ng-click="selAutoPrice(price,$event)"><span ng-bind="price.text+':'+price.value"></span></div>
            </div>
            <div class="extra-list-ctn"></div>
        </div>
        {{-- 价格选择弹出框end--}}

        {{-- 折后价格选择弹出框start--}}
        <div ng-show="showAutoTruePrice" ng-style="autoTruePriceStyle" class="ui-droplist-wrap">
            <div class="droplist">
                <div class="list-item" ng-repeat="truePrice in currentTruePrices" ng-click="selAutoTruePrice(truePrice,$event)"><span ng-bind="truePrice.text+':'+truePrice.value"></span></div>
            </div>
            <div class="extra-list-ctn"></div>
        </div>
        {{-- 折后价格选择弹出框end--}}

        {{-- 提示框start--}}
        <div class="alert alert-danger alert-dismissable alertmsg">
            <a class="close" onclick="$('.alert').hide()">×</a> <strong>提示:</strong>
            <span ng-bind="warningMsg" class="ng-binding"></span>
        </div>
        {{-- 提示框end--}}

        {{--尺码 颜色弹出框start--}}
        <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable twoDisDiv" tabindex="-1" role="dialog" style="position: absolute; height: auto; width: 800px; top: 444px; left: 555px; display: none;" aria-describedby="twoDisDiv" aria-labelledby="ui-id-2">
            <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
                <span id="ui-id-2" class="ui-dialog-title"></span>
                <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close">
                    <span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span>
                    <span class="ui-button-text">close</span>
                </button>
            </div>
            <div id="twoDisDiv" style="width: auto; min-height: 79px; max-height: none; height: auto;" class="ui-dialog-content ui-widget-content">
                <!-- 批量设置数量 -->
                <div class="batchSetNumber">
                    <a class="setAllBtn" ng-show="!allNumberBatchSetting &amp;&amp; !colorNumberBatchSetting &amp;&amp; !sizeNumberBatchSetting" ng-click="toSetAllNumber();">批量设置所有</a>
                    <input ng-pattern="/^-*[0-9]*$/" ng-show="allNumberBatchSetting || colorNumberBatchSetting || sizeNumberBatchSetting" type="number" min="0" ng-model="twoDisTableSetNumber" id="twoDisTableSetNumber" class="ng-pristine ng-valid ng-valid-number ng-valid-min ng-valid-pattern ng-hide" />
                    <span ng-show="allNumberBatchSetting || colorNumberBatchSetting || sizeNumberBatchSetting" class="ng-hide">
                        <button ng-show="allNumberBatchSetting" ng-click="allNumberBatchSet();" class="btn-normal btn-small ng-hide">设置</button>
                        <button ng-show="colorNumberBatchSetting" ng-click="colorNumberBatchSet();" class="btn-normal btn-small ng-hide">设置</button>
                        <button ng-show="sizeNumberBatchSetting" ng-click="sizeNumberBatchSet();" class="btn-normal btn-small ng-hide">设置</button> &nbsp;
                        <button ng-click="numberBatchSetCancel();" class="btn-normal btn-small">取消</button>&nbsp;
                    </span>
                    <span ng-show="!allNumberBatchSetting &amp;&amp; !colorNumberBatchSetting &amp;&amp; !sizeNumberBatchSetting" class="tips-text">（点击某一颜色或尺码,可批量设置该颜色或尺码的数量）</span>

                    <span ng-show="colorNumberBatchSetting || sizeNumberBatchSetting" class="tips-text ng-binding ng-hide" ng-bind="numberBatchSetTips"></span>
                </div>

                <table class="inputTable table table-bordered" ng-keydown="pressTable($event);">
                    <thead>
                    <tr>
                        <th></th>
                        <th scope="col" ng-repeat="(index,size) in currentSizes | orderBy:['showOrder','id']" class="ng-scope">
                            <a class="sel-a" ng-click="toSetSizeNumber(index);">
                                <span ng-bind="size.name" class="ng-binding"></span>
                            </a>
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="(index,color) in currentColors | orderBy:['showOrder','id']" class="ng-scope">
                        <th scope="row"><a class="sel-a" ng-click="toSetColorNumber(index);"><span ng-bind="color.name" class="ng-binding"></span></a>
                        </th>
                        <td class="inputTableTd ng-scope" ng-repeat="size in currentSizes | orderBy:['showOrder','id']">
                            <input autofocus="" type="number" min="0" ng-pattern="/^-*[0-9]*$/" ng-model="color[size.id]" indexx="0" indexy="0" id="goods0_0" ng-click="clickInput($event);" class="ng-pristine ng-valid ng-valid-number ng-valid-min ng-valid-pattern" />
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div class="text-center">
                    <button id="twoDisConfirmBtn" ng-click="twoDisConfirm()" class="btn-normal">确认(Enter)</button>
                </div>
            </div>
        </div>
        {{--尺码 颜色弹出框end--}}
    </div>
</div>
<script>
    var base = '{{ env('APP_URL') }}';
    var allSizes = {!! json_encode($sizes) !!};
    var allColors = {!! json_encode($colors) !!};
    var onLoadOrdersSn = '';
    var wholesaleOrdersSn = '';
    var firstPageSupplierJson = {!! json_encode($suppliers) !!};
    var order_type = '{{ $order_type }}';
    var plan_id = {{isset($plan_id)?$plan_id:0}};  //盘点的时候才使用该字段
    @if($order_type=='transfer')
        $('#outShopId').select2({
            placeholder: '请选择',
            allowClear: true
        });

        $('#inShopId').select2({
            placeholder: '请选择',
            allowClear: true
        });
    @endif

    /**
     * 右下角弹窗函数,默认3秒后消隐,消隐将历时0.5s.
     * @param title 标题
     * @param content 内容
     */
    function showMessage(title, content) {
	    var options = {};
	    $("#popTitle").html(title);
	    $("#popIntro").html(content);
	    $("#pop").show("slow", closeMessage(3000));
    }

    /**
     * 右下角弹窗关闭函数
     */
    function closeMessage(timeout) {
	    if (timeout && timeout > 0) {
		    setTimeout(function () {
			    $("#pop:visible").removeAttr("style").fadeOut(500);
		    }, timeout);
	    }
    }

</script>

{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-animate.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-resource.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-sanitize.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/ng-currency.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-cookie.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-locale_zh-cn.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/ui-bootstrap-tpls-0.10.0.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-strap.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/angular-strap.tpl.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/admin/js/mulselect.js') !!}

{!! Html::script(env("APP_URL").'/assets/backend/libs/jqGrid/js/i18n/grid.locale-cn.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/jqGrid/js/jquery.jqGrid.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/jquery-ui-1.9.2/js/jquery-ui-1.9.2.custom.js') !!}

@include('shop-backend::includes.loading-script')
@include('shop-backend::purchase.includes.common')
@include('shop-backend::purchase.includes.purchase')